package com.zysstudy.collection;

/**
 * @author zhaoyoushui
 * @date 2025/7/7 18:59
 * @Description
 * @Copyright 南京优通信息科技股份有限公司
 */
public class StringStudy {

    public static void main(String[] args) {
        String s1="hello world";
        String s2="hello world ";
        Boolean res = s1.contains(s2);
        System.out.println("字符串1:"+s1+"是否包含了"+"字符串2:"+s2+","+"比较结果是："+res);

        Boolean res1 = s2.contains(s1);
        System.out.println("字符串2:"+s2+"是否包含了"+"字符串1:"+s1+","+"比较结果是："+res1);

        Boolean res2 = s1.equals(s2);
        System.out.println("字符串2:"+s2+"是否等于"+"字符串1:"+s1+","+"比较结果是："+res2);

        StringBuilder sb = new StringBuilder();
        sb.append("java");
        System.out.println("添加字符串到末尾:"+sb);
        sb.insert(  sb.length(), "hello ");
        System.out.println("在指定的位置插入字符串:"+sb);
        sb.replace(5, 6, ",");
        System.out.println("替换指定位置的字符串:"+sb);
        sb.delete(5, 6);
        System.out.println("删除指定位置的字符:"+sb);
        sb.reverse();
        System.out.println("字符串翻转："+sb);
        System.out.println("字符串的长度为:"+sb.length());



    }
}
